<!-- 一次系统图 -->
<template>
	<div class="dashboard-container">
		<page-header :headerTitle="$t('message.systemChartShow.pageTitle')" :showWeather="false" />
		<div class="power-unit">{{ $t('message.systemChartShow.pagePowerUnit') }} : kW</div>
		<div class="spacer"></div>

		<el-row :gutter="15" class="site-container">
			<el-col :span="4" v-for="(site, index) in networkSites" :key="index" class="site-col">
				<div class="top-line"></div>
				<div class="site-header">
					<h3>{{ site.name }}</h3>
					&nbsp;
					<div class="header-line"></div>
				</div>
				<div class="node-container">
					<div v-for="(node, idx) in site.nodes" :key="idx" class="node-item">
						<div class="node-header">
							<span>P</span>
							<div class="space"></div>
							<span @click="goCurveAnalyse" class="node-value">{{ node.value }}</span>
							<div class="space"></div>
							<div class="node-icon"></div>
							<div class="space"></div>
							<span class="node-name">{{ node.name }}</span>
						</div>
					</div>
				</div>
			</el-col>
		</el-row>
	</div>
</template>

<script lang="ts">
import { useRouter } from 'vue-router';
import pageHeader from '../../components/pageHeader/index.vue';
import { defineComponent, reactive, toRefs } from 'vue';

export default defineComponent({
	name: 'systemChartShow',

	components: { pageHeader },

	setup() {
		const router = useRouter();

		// 生成站点数据
		const generateSites = (count: number) => {
			return Array.from({ length: count }, (_, i) => ({
				name: `${i + 1}#并网点`,
				nodes: [
					{ value: '76.97', name: `${String(i + 1).padStart(2, '0')}NB01` },
					{ value: '76.97', name: `${String(i + 1).padStart(2, '0')}NB02` },
					{ value: '76.97', name: `${String(i + 1).padStart(2, '0')}NB03` },
				],
			}));
		};

		const state = reactive({
			networkSites: generateSites(30),
		});

		const goCurveAnalyse = () => {
			router.push({
				name: 'lineAnalyseQuery',
			});
		};

		return {
			goCurveAnalyse,
			...toRefs(state),
		};
	},
});
</script>

<style lang="scss" scoped>
.dashboard-container {
	padding: 20px;
}

.power-unit {
	text-align: right;
	letter-spacing: 1.5px;
}

.spacer {
	height: 1rem;
}

.site-container {
	font-size: 0.8rem;
}

.site-col {
	margin-bottom: 2.3rem;
}

.top-line {
	border-top: 0.1rem solid red;
	margin: 0 1rem;
}

.site-header {
	display: flex;
	justify-content: center;
	align-items: flex-end;

	h3 {
		text-align: center;
		margin: 0;
	}
}

.header-line {
	border-right: 0.15rem solid red;
	height: 3.5rem;
}

.node-container {
	border: 1px #ccc dashed;
	padding: 0.8rem;
}

.node-item {
	margin-bottom: 0.8rem;
}

.node-header {
	display: flex;
	font-weight: bold;
	align-items: center;
	justify-content: space-between;
}

.space {
	width: 1rem;
}

.node-value {
	border-bottom: 0.09rem solid #fff;
	cursor: pointer;

	&:hover {
		color: #409eff;
	}
}

.node-icon {
	border: 0.3rem solid red;
}

.node-name {
	white-space: nowrap;
}
</style>
